package org.woosiyuan.util;

import java.io.PrintWriter;

public class Command {
	
	private PrintWriter out;
	private int cmd;
	private String data;
	
	final int MOVE_FOWARD = 1;
	final int MOVE_BACK = 2;
	final int MOVE_LEFT = 3;
	final int MOVE_RIGHT = 4;
	final int TURN_LEFT = 5;
	final int TURN_RIGHT = 6;
	
	public Command(PrintWriter out)
	{
		this.out = out;
	}
	public void moveFoward()
	{
		sendCommand(MOVE_FOWARD,data);
	}
	public void moveBack()
	{
		sendCommand(MOVE_BACK,data);
	}
	public void moveLeft()
	{
		sendCommand(MOVE_LEFT,data);
	}
	public void moveRight()
	{
		sendCommand(MOVE_RIGHT,data);
	}
	public void turnLeft()
	{
		sendCommand(TURN_LEFT,data);
	}
	public void turnRight()
	{
		sendCommand(TURN_RIGHT,data);
	}
	
	private void sendCommand(int cmd,String data)
	{
		out.println(cmd + ":" + data);
		out.flush();
	}
}
